from flask import g, Blueprint, render_template

from decorations import login_required

bp = Blueprint("admin", __name__, url_prefix="/")


@bp.route("/login")
def login():
    return render_template("login.html")


@bp.route("/register")
def register():
    return render_template("register.html")


@bp.route("/")
@login_required
def index():
    try:
        username = g.user.get("username")
    except:
        username = "未登录"
    content = {
        "username": username,
    }
    return render_template("index.html", **content)
